<?php
/*
 *author:Yangligao
 *Date:2013-10-5
 */


$latest_id = isset($_GET['food_id'])?$_GET['food_id']:'';

$latestOld = array();
//如果COOKIE[''myproduct]存在需要保留里面的值
if(isset($_COOKIE['latestData'])){
	if(!empty($_COOKIE['latestData'])){
		
		$latestOld = unserialize($_COOKIE['latestData']);
		if(count(unserialize($_COOKIE['latestData'])) == 10){
		
			array_shift($latestOld);
		}
	}
}
if(!empty($latest_id)){

	$latestOld["$latest_id"] = $latest_id;
	setcookie('latestData',serialize($latestOld),time()+3600*24,'/');
}
$latestArr = array();
foreach($latestOld as $key=>$value){
	//通过$key的值获取产品信息
	$foodModel = new FoodModel();
	$latestRes = $foodModel->food_select('food_id,food_name,food_pic,food_singleprice,food_userprice',"where food_id={$value}");
	$latestArr[] = $latestRes[0];
}
$smarty->assign('latestRes',$latestArr);
?>
